package com.yoomiito.app.present.my.activity

import cn.droidlover.xdroidmvp.net.ApiException
import cn.droidlover.xdroidmvp.net.ApiSubscriber
import cn.droidlover.xdroidmvp.net.XApi
import com.yoomiito.app.base.AppConfig
import com.yoomiito.app.base.BaseActPresenter
import com.yoomiito.app.model.BaseList
import com.yoomiito.app.model.home.YouPinHotSearch
import com.yoomiito.app.model.my.BankSearch
import com.yoomiito.app.net.YmApi
import com.yoomiito.app.showToast
import com.yoomiito.app.ui.my.BankSearchActivity

class BankSearchPresenter(appConfig: AppConfig) : BaseActPresenter<BankSearchActivity>(appConfig) {

    fun getBankSearch(name: String) {
        YmApi.getYmService()
            .getBankSearch(name)
            .compose(v?.bindToLifecycle())
            .compose(XApi.getApiTransformerData())
            .compose(XApi.getScheduler())
            .subscribe(object : ApiSubscriber<BaseList<BankSearch>>() {
                override fun onSuccess(t: BaseList<BankSearch>?) {
                    v?.dismissLoading()
                    t?.data?.let { v.setData(it) }

                }

                override fun onFail(error: ApiException?) {
                    v?.dismissLoading()
                    error?.msg?.showToast()
                }
            })
    }



}